
using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Entity;

namespace Data
{
	public class DAUsuario
	{
	      
		public static void Insert(BEUsuario oBE)
		{
			SqlDatabase sqlClient = new SqlDatabase(Configuracion.GetConnection);
			DbCommand dbCmd = sqlClient.GetStoredProcCommand("sp_insertUsuario");
	      
	        sqlClient.AddInParameter(dbCmd, "@Log_Usu", DbType.String, oBE.Log_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Pass_Usu", DbType.String, oBE.Pass_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Nom_Usu", DbType.String, oBE.Nom_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Ape_Usu", DbType.String, oBE.Ape_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Ema_Usu", DbType.String, oBE.Ema_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Car_Usu", DbType.String, oBE.Car_Usu);
	         

	        sqlClient.AddInParameter(dbCmd, "@Est_Usu", DbType.Int32, oBE.Est_Usu);
	         

			sqlClient.ExecuteNonQuery(dbCmd);
		}
	      
		public static void Update(BEUsuario oBE)
		{
			SqlDatabase sqlClient = new SqlDatabase(Configuracion.GetConnection);			
			DbCommand dbCmd = sqlClient.GetStoredProcCommand("sp_updateUsuario");
	      
			sqlClient.AddInParameter(dbCmd, "@Log_Usu", DbType.String, oBE.Log_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Pass_Usu", DbType.String, oBE.Pass_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Nom_Usu", DbType.String, oBE.Nom_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Ape_Usu", DbType.String, oBE.Ape_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Ema_Usu", DbType.String, oBE.Ema_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Car_Usu", DbType.String, oBE.Car_Usu);
	       

			sqlClient.AddInParameter(dbCmd, "@Est_Usu", DbType.Int32, oBE.Est_Usu);
	       

		//
	      
			sqlClient.ExecuteNonQuery(dbCmd);
		}
	      
		public static void Delete(BEUsuario oBE)
		{
			SqlDatabase sqlClient = new SqlDatabase(Configuracion.GetConnection);
			DbCommand dbCmd = sqlClient.GetStoredProcCommand("sp_deleteUsuario");
	      
	        sqlClient.AddInParameter(dbCmd, "@Cod_Usu", DbType.Int32, oBE.Cod_Usu);
	       

	        sqlClient.ExecuteNonQuery(dbCmd);
	    }
	      
		public static DataTable ObtenerTodos()
		{
			SqlDatabase sqlClient = new SqlDatabase(Configuracion.GetConnection);        
			DbCommand dbCmd = sqlClient.GetStoredProcCommand("sp_ObtenerTodosUsuario");
			return sqlClient.ExecuteDataSet(dbCmd).Tables[0];
		}
	      
		public static DataTable ObtenerUno(BEUsuario oBE)
		{
			SqlDatabase sqlClient = new SqlDatabase(Configuracion.GetConnection);
			DbCommand dbCmd = sqlClient.GetStoredProcCommand("sp_ObtenerUnoUsuario");
	      
	        sqlClient.AddInParameter(dbCmd, "@Cod_Usu", DbType.Int32, oBE.Cod_Usu);
	       

	        return sqlClient.ExecuteDataSet(dbCmd).Tables[0];
		}
	}
}
      